<%--
  - Author		:	이 영호(Youngho Lee)	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<c:choose>
	<c:when test="${param.boardType eq 'notice'}">
		<c:set var="type" value="1" />
		<c:set var="boardTitle" value="공지사항" />
		<c:set var="boardImg" value="subtit_04_1.gif" />
		<c:set var="boardListUrl" value="notice.do" /> 
	</c:when>
	<c:when test="${param.boardType eq 'qna'}">
		<c:set var="type" value="2" />
		<c:set var="boardTitle" value="문의하기" />
		<c:set var="boardImg" value="subtit_04_2.gif" />
		<c:set var="boardListUrl" value="qna.do" /> 
	</c:when>
	<c:when test="${param.boardType eq 'file'}">
		<c:set var="type" value="3" />
		<c:set var="boardTitle" value="자료실" />
		<c:set var="boardImg" value="subtit_04_3.gif" />
		<c:set var="boardListUrl" value="file.do" /> 
	</c:when>
</c:choose>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/utils.js" />"></script>
		<script type="text/javascript">
			$(function(){
				$(".popupWrap").draggable({ cursor: "pointer", handle: ".pTitle" });
			});
			
			var pwChkFlag = false;
			function validation(){
				try{
					with(document.frm){
						var stringUtils = new StringUtils();
						
						if((title.value).replace(/\s/g, '') == ""){
							alert("[제목]은 필수 입력 항목입니다.");
							title.focus();
							return false;
						}
						if((cont.value).replace(/\s/g, '') == ""){
							alert("[내용]은 필수 입력 항목입니다.");
							cont.focus();
							return false;
						}
						if(stringUtils.computeSize(cont.value) > 100000){
							alert("[내용]은 100000byte까지 입력할 수 있습니다.\\n(현재 입력 byte : "+stringUtils.computeSize(cont.value)+")");
							cont.focus();
							return false;
						}
						
						if((password.value).replace(/\s/g, '') != "" && ! pwChkFlag){
							$("#password").html(password.value);
							$(".pBoard").show();
							return false;
						}
					}
				}catch(err){
					alert(err);
					return false;	
				}
				
				if(! confirm("문의를 <c:if test="${empty board}">등록</c:if><c:if test="${not empty board}">수정</c:if> 하시겠습니까?")){
					return false;
				}
				
				return true;
			}

		</script>
	</head>
	<body>
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="contMenuTitle">
					<img src="<c:url value="${dirImages}/subtit_04_2.gif" />" title="문의하기" alt="문의하기">
				</div>
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="문의하기" alt="문의하기" > 문의하기
				</div>
				<form name="frm" method="post" enctype="multipart/form-data" action="<c:url value="/board/submit.do" />" onsubmit="return validation();">
					<input type="hidden" name="boardType" value="${param.boardType}" />
					<input type="hidden" name="type" value="${type}" />
					<input type="hidden" name="maxnum" value="${param.maxnum}" />
					<input type="hidden" name="page" value="${param.page}" />
					<input type="hidden" name="searchType" value="${param.searchType}" />
					<input type="hidden" name="searchWord" value="${param.searchWord}" />
					<table class="formTbl">
						<colgroup>
							<col width="100px" />
							<col width="367px" />
							<col width="100px" />
							<col width="*" />
						</colgroup>
						<tbody>
							<tr>
								<th>작성자</th>
								<th>
									${sessionScope.userNm}
								</th>
								<th>작성일</th>
								<th>
									<jsp:useBean id="now" class="java.util.Date" />
									<fmt:formatDate value="${now}" pattern="yyyy/MM/dd" /> 
								</th>
							</tr>
							<tr>
								<th>제목</th>
								<td>
									<input type="text" name="title" title="제목" alt="제목" maxlength="25" style="width: 340px;" value="${board.title}" />
								</td>
								<th>비밀번호</th>
								<td>
									<input type="password" name="password" title="비밀번호" alt="비밀번호" maxlength="4" value="${board.password}"/>
								</td>
							</tr>
							<tr>
								<th>내용</th>
								<td colspan="3">
									<textarea name="cont" style="width: 615px; height: 320px;margin: 5px 0;">${board.cont}</textarea>
								</td>
							</tr>
						</tbody>
					</table>
					<div class="btnWrap rightBtnWrap">
						<c:choose>
							<c:when test="${param.fAct eq 'modify'}">
								<input type="hidden" name="idx" value="${board.idx}">
								<input type="hidden" name="fAct" value="modify">
								<input type="submit" class="btn btn_revision" alt="수정" title="수정" value="">
							</c:when>
							<c:otherwise>
								<input type="submit" class="btn btn_register" alt="등록" title="등록" value="">
							</c:otherwise>
						</c:choose>
						<input type="button" class="btn btn_cancel" alt="취소" title="취소" onclick="javascript:document.listFrm.submit();">
					</div>
				</form>
			</div>
		</div>
		<div class="popupWrap pBoard" style="display: none;">
			<div class="pTitle">
				주의사항
				<div class="pClose btn" onclick="javascript:pwChkFlag=true;$('.pBoard').hide();"></div>
			</div>
			<div class="pCont">
				<p>
					비밀글 설정을 위해 입력하신 비밀번호는 "<font class="redFont" id="password"></font>"입니다.<br />
					비밀번호 분실시 작성자도 문의 글을 보실 수 없으니 잊어버리지 않도록 주의하세요.
				</p>
			</div>
			<div class="btnWrap centerBtnWrap">
				<input type="button" class="btn btn_ok" alt="확인" title="확인" onclick="javascript:pwChkFlag=true;$('.pBoard').hide();document.frm.submit();">
			</div>
		</div>
		<form name="listFrm" method="post" action="<c:url value="/board/qna.do" />">
			<input type="hidden" name="maxnum" value="${param.maxnum}" />
			<input type="hidden" name="page" value="${param.page}" />
			<input type="hidden" name="searchType" value="${param.searchType}" />
			<input type="hidden" name="searchWord" value="${param.searchWord}" />
		</form>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
	</body>
</html> 